﻿Public Class Cliente : Implements IEquatable(Of Cliente)
    Private _Nombre As String
    Private _Email As String
    Private _NumTarjeta As String
    Private _CaducidadTarjeta As String

    Public Sub New(ByVal nombre As String, ByVal password As String, ByVal email As String, ByVal numtarjeta As String, ByVal caducidadtarjeta As String)
        Me.Nombre = nombre
        Me.Password = password
        Me.Email = email
        Me.NumTarjeta = numtarjeta
        Me.CaducidadTarjeta = caducidadtarjeta
    End Sub


    Public Property Nombre As String

        Get

            Return _Nombre
        End Get
        Set(value As String)
            If value.Length < 2 Then
                _Nombre = "Error"

            Else
                _Nombre = value

            End If


        End Set
    End Property
    Public Property Email As String
        Get

            Return _Email
        End Get
        Set(value As String)
            If value.Length < 5 OrElse value.IndexOf("@") = -1 OrElse value.IndexOf("@") <> value.LastIndexOf("@") Then
                _Email = "Error"

            Else
                _Email = value

            End If


        End Set
    End Property
    Public Property NumTarjeta As String
        Get

            Return _NumTarjeta
        End Get
        Set(value As String)
            If value.Length <> 16 Then
                _NumTarjeta = "Error"

            Else
                _NumTarjeta = value

            End If


        End Set
    End Property
    Public Property Password As String
     

    Public Property CaducidadTarjeta As String
        Get
            Return _CaducidadTarjeta
        End Get
        Set(value As String)

            Dim datos() As String = value.Split("/")
            Dim año As Integer = Integer.Parse(datos(1)) + 2000
            Dim mes As Integer = Integer.Parse(datos(0))
            If (año < Today.Year) OrElse (año = Today.Year AndAlso mes < Today.Month) Then
                _CaducidadTarjeta = "Error"
            Else
                _CaducidadTarjeta = value
            End If

        End Set
    End Property
    Public Sub New()

    End Sub

    Public Overloads Function Equals(ByVal other As Cliente) As Boolean Implements System.IEquatable(Of Cliente).Equals
        Return other IsNot Nothing AndAlso Me.Nombre.ToLower = other.Nombre.ToLower

    End Function
  
    


End Class
